package mylibrary.xml.demo.suit;

import org.w3c.dom.Document;
import org.w3c.dom.Element;

public class CipherData {

	private Document doc = null;
	
	private Element cipherData = null;
	
	protected boolean elementAppendedToDoc = false;
	
	public CipherData(Document document) {
		doc = document;
		cipherData = doc.createElement("CipherData");
	}
	
	public void setValue(String value) {
		Element tempElem = doc.createElement("CipherValue");
		tempElem.appendChild(doc.createTextNode(value));
		cipherData.appendChild(tempElem);
	}
	
	public void setCipherReference(String uriValue, Element transforms) {
		Element tempElem = doc.createElement("CipherReference");
		tempElem.setAttribute("URI", uriValue);
		
		if(transforms != null) {
			tempElem.appendChild(transforms);
		}
	}
	
	public Document getCipherData() {
		if(elementAppendedToDoc == false) {
			doc.appendChild(cipherData);
			elementAppendedToDoc = true;
		}
		return doc;
	}
}
